home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / ARCDEVIC.{5I < prev    next >
Text File  |  1999-09-17  |  13KB  |  355 lines

  1. /*
  2.  * INET        An implementation of the TCP/IP protocol suite for the LINUX
  3.  *        operating system.  NET  is implemented using the  BSD Socket
  4.  *        interface as the means of communication with the user level.
  5.  *
  6.  *        Definitions for the ARCnet handlers.
  7.  *
  8.  * Version:    $Id: arcdevice.h,v 1.3 1997/11/09 11:05:05 mj Exp $
  9.  *
  10.  * Authors:    Avery Pennarun <apenwarr@bond.net>
  11.  *              David Woodhouse <dwmw2@cam.ac.uk>
  12.  *
  13.  *        This program is free software; you can redistribute it and/or
  14.  *        modify it under the terms of the GNU General Public License
  15.  *        as published by the Free Software Foundation; either version
  16.  *        2 of the License, or (at your option) any later version.
  17.  *
  18.  */
  19. #ifndef _LINUX_ARCDEVICE_H
  20. #define _LINUX_ARCDEVICE_H
  21.  
  22. #include <linux/config.h>
  23. #include <linux/if_arcnet.h>
  24.  
  25. #ifdef __KERNEL__
  26.  
  27. #define ARC_20020     1
  28. #define ARC_RIM_I     2
  29. #define ARC_90xx      3
  30. #define ARC_90xx_IO   4
  31.  
  32. #define MAX_ARCNET_DEVS 8
  33.  
  34.  
  35. /* The card sends the reconfiguration signal when it loses the connection to
  36.  * the rest of its network. It is a 'Hello, is anybody there?' cry.  This
  37.  * usually happens when a new computer on the network is powered on or when
  38.  * the cable is broken.
  39.  *
  40.  * Define DETECT_RECONFIGS if you want to detect network reconfigurations.
  41.  * Recons may be a real nuisance on a larger ARCnet network; if you are a
  42.  * network administrator you probably would like to count them.
  43.  * Reconfigurations will be recorded in stats.tx_carrier_errors (the last
  44.  * field of the /proc/net/dev file).
  45.  *
  46.  * Define SHOW_RECONFIGS if you really want to see a log message whenever
  47.  * a RECON occurs.
  48.  */
  49. #define DETECT_RECONFIGS
  50. #undef SHOW_RECONFIGS
  51.  
  52.  
  53. /* RECON_THRESHOLD is the maximum number of RECON messages to receive within
  54.  * one minute before printing a "cabling problem" warning.  You must have
  55.  * DETECT_RECONFIGS enabled if you want to use this.  The default value
  56.  * should be fine.
  57.  *
  58.  * After that, a "cabling restored" message will be printed on the next IRQ
  59.  * if no RECON messages have been received for 10 seconds.
  60.  *
  61.  * Do not define RECON_THRESHOLD at all if you want to disable this feature.
  62.  */
  63. #define RECON_THRESHOLD 30
  64.  
  65.  
  66. /* Define this to the minimum "timeout" value.  If a transmit takes longer
  67.  * than TX_TIMEOUT jiffies, Linux will abort the TX and retry.  On a large
  68.  * network, or one with heavy network traffic, this timeout may need to be
  69.  * increased.  The larger it is, though, the longer it will be between
  70.  * necessary transmits - don't set this too large.
  71.  */
  72. #define TX_TIMEOUT 20
  73.  
  74.  
  75. /* Display warnings about the driver being an ALPHA version.
  76.  */
  77. #undef ALPHA_WARNING
  78.  
  79.  
  80. /* New debugging bitflags: each option can be enabled individually.
  81.  *
  82.  * These can be set while the driver is running by typing:
  83.  *    ifconfig arc0 down metric 1xxx HOSTNAME
  84.  *        where 1xxx is 1000 + the debug level you want
  85.  *        and HOSTNAME is your hostname/ip address
  86.  * and then resetting your routes.
  87.  *
  88.  * An ioctl() should be used for this instead, someday.
  89.  *
  90.  * Note: only debug flags included in the ARCNET_DEBUG_MAX define will
  91.  *   actually be available.  GCC will (at least, GCC 2.7.0 will) notice
  92.  *   lines using a BUGLVL not in ARCNET_DEBUG_MAX and automatically optimize
  93.  *   them out.
  94.  */
  95. #define D_NORMAL    1    /* important operational info        */
  96. #define D_EXTRA        2    /* useful, but non-vital information    */
  97. #define    D_INIT        4    /* show init/probe messages        */
  98. #define D_INIT_REASONS    8    /* show reasons for discarding probes    */
  99. /* debug levels below give LOTS of output during normal operation! */
  100. #define D_DURING    16    /* trace operations (including irq's)    */
  101. #define D_TX        32    /* show tx packets            */
  102. #define D_RX        64    /* show rx packets            */
  103. #define D_SKB        128    /* show skb's                */
  104.  
  105. #ifndef ARCNET_DEBUG_MAX
  106. #define ARCNET_DEBUG_MAX (~0)        /* enable ALL debug messages     */
  107. #endif
  108.  
  109. #ifndef ARCNET_DEBUG
  110. #define ARCNET_DEBUG (D_NORMAL|D_EXTRA)
  111. #endif
  112. extern int arcnet_debug;
  113.  
  114. /* macros to simplify debug checking */
  115. #define BUGLVL(x) if ((ARCNET_DEBUG_MAX)&arcnet_debug&(x))
  116. #define BUGMSG2(x,msg,args...) do { BUGLVL(x) printk(msg, ## args); } while (0)
  117. #define BUGMSG(x,msg,args...) \
  118.     BUGMSG2(x,"%s%6s: " msg, \
  119.             x==D_NORMAL    ? KERN_WARNING : \
  120.       x<=D_INIT_REASONS    ? KERN_INFO    : KERN_DEBUG , \
  121.     dev->name , ## args)
  122.  
  123.  
  124. #define SETMASK AINTMASK(lp->intmask)
  125.  
  126.     /* Time needed to resetthe card - in jiffies.  This works on my SMC
  127.      * PC100.  I can't find a reference that tells me just how long I
  128.      * should wait.
  129.      */
  130. #define RESETtime (HZ * 3 / 10)        /* reset */
  131.  
  132.     /* these are the max/min lengths of packet data. (including
  133.      * ClientData header)
  134.      * note: packet sizes 250, 251, 252 are impossible (God knows why)
  135.      *  so exception packets become necessary.
  136.      *
  137.      * These numbers are compared with the length of the full packet,
  138.      * including ClientData header.
  139.      */
  140. #define MTU    253    /* normal packet max size */
  141. #define MinTU    257    /* extended packet min size */
  142. #define XMTU    508    /* extended packet max size */
  143.  
  144.     /* status/interrupt mask bit fields */
  145. #define TXFREEflag    0x01            /* transmitter available */
  146. #define TXACKflag       0x02            /* transmitted msg. ackd */
  147. #define RECONflag       0x04            /* system reconfigured */
  148. #define TESTflag        0x08            /* test flag */
  149. #define RESETflag       0x10            /* power-on-reset */
  150. #define RES1flag        0x20            /* reserved - usually set by jumper */
  151. #define RES2flag        0x40            /* reserved - usually set by jumper */
  152. #define NORXflag        0x80            /* receiver inhibited */
  153.  
  154.        /* Flags used for IO-mapped memory operations */
  155. #define AUTOINCflag     0x40    /* Increase location with each access */
  156. #define IOMAPflag       0x02    /* (for 90xx) Use IO mapped memory, not mmap */
  157. #define ENABLE16flag    0x80    /* (for 90xx) Enable 16-bit mode */
  158.  
  159.        /* in the command register, the following bits have these meanings:
  160.         *                0-2     command
  161.         *                3-4     page number (for enable rcv/xmt command)
  162.         *                 7      receive broadcasts
  163.         */
  164. #define NOTXcmd         0x01            /* disable transmitter */
  165. #define NORXcmd         0x02            /* disable receiver */
  166. #define TXcmd           0x03            /* enable transmitter */
  167. #define RXcmd           0x04            /* enable receiver */
  168. #define CONFIGcmd       0x05            /* define configuration */
  169. #define CFLAGScmd       0x06            /* clear flags */
  170. #define TESTcmd         0x07            /* load test flags */
  171.  
  172.        /* flags for "clear flags" command */
  173. #define RESETclear      0x08            /* power-on-reset */
  174. #define CONFIGclear     0x10            /* system reconfigured */
  175.  
  176.     /* flags for "load test flags" command */
  177. #define TESTload        0x08            /* test flag (diagnostic) */
  178.  
  179.     /* byte deposited into first address of buffers on reset */
  180. #define TESTvalue       0321         /* that's octal for 0xD1 :) */
  181.  
  182.     /* for "enable receiver" command */
  183. #define RXbcasts        0x80            /* receive broadcasts */
  184.  
  185.     /* flags for "define configuration" command */
  186. #define NORMALconf      0x00            /* 1-249 byte packets */
  187. #define EXTconf         0x08            /* 250-504 byte packets */
  188.  
  189.     /* Starts receiving packets into recbuf.
  190.      */
  191. #define EnableReceiver()    ACOMMAND(RXcmd|(recbuf<<3)|RXbcasts)
  192.  
  193.  
  194.  
  195. #define JIFFER(time) for (delayval=jiffies+time; time_before(jiffies,delayval);) ;
  196.  
  197.     /* a complete ARCnet packet */
  198. union ArcPacket
  199. {
  200.     struct archdr hardheader;    /* the hardware header */
  201.     u_char raw[512];        /* raw packet info, incl ClientData */
  202. };
  203.  
  204.  
  205.     /* the "client data" header - RFC1201 information
  206.      * notice that this screws up if it's not an even number of bytes
  207.      * <sigh>
  208.      */
  209. struct ClientData
  210. {
  211.     /* data that's NOT part of real packet - we MUST get rid of it before
  212.      * actually sending!!
  213.      */
  214.     u_char  saddr,        /* Source address - needed for IPX */
  215.         daddr;        /* Destination address */
  216.  
  217.     /* data that IS part of real packet */
  218.     u_char    protocol_id,    /* ARC_P_IP, ARC_P_ARP, etc */
  219.         split_flag;    /* for use with split packets */
  220.     u_short    sequence;    /* sequence number */
  221. };
  222. #define EXTRA_CLIENTDATA (sizeof(struct ClientData)-4)
  223.  
  224.  
  225.     /* the "client data" header - RFC1051 information
  226.      * this also screws up if it's not an even number of bytes
  227.      * <sigh again>
  228.      */
  229. struct S_ClientData
  230. {
  231.     /* data that's NOT part of real packet - we MUST get rid of it before
  232.      * actually sending!!
  233.      */
  234.     u_char  saddr,        /* Source address - needed for IPX */
  235.         daddr,        /* Destination address */
  236.         junk;        /* padding to make an even length */
  237.  
  238.     /* data that IS part of real packet */
  239.     u_char    protocol_id;    /* ARC_P_IP, ARC_P_ARP, etc */
  240. };
  241. #define S_EXTRA_CLIENTDATA (sizeof(struct S_ClientData)-1)
  242.  
  243.  
  244. /* "Incoming" is information needed for each address that could be sending
  245.  * to us.  Mostly for partially-received split packets.
  246.  */
  247. struct Incoming
  248. {
  249.     struct sk_buff *skb;        /* packet data buffer             */
  250.     unsigned char lastpacket,    /* number of last packet (from 1) */
  251.               numpackets;    /* number of packets in split     */
  252.     u_short sequence;        /* sequence number of assembly      */
  253. };
  254.  
  255. struct Outgoing
  256. {
  257.     struct sk_buff *skb;        /* buffer from upper levels */
  258.     struct ClientData *hdr;        /* clientdata of last packet */
  259.     u_char *data;            /* pointer to data in packet */
  260.     short length,            /* bytes total */
  261.           dataleft,            /* bytes left */
  262.           segnum,            /* segment being sent */
  263.           numsegs,            /* number of segments */
  264.           seglen;            /* length of segment */
  265. };
  266.  
  267.  
  268. struct arcnet_local {
  269.   struct net_device_stats stats;
  270.   u_short sequence;    /* sequence number (incs with each packet) */
  271.   u_short aborted_seq;
  272.   u_char stationid,    /* our 8-bit station address */
  273.     recbuf,        /* receive buffer # (0 or 1) */
  274.     txbuf,        /* transmit buffer # (2 or 3) */
  275.     txready,        /* buffer where a packet is ready to send */
  276.     config,        /* current value of CONFIG register */
  277.     timeout,        /* Extended timeout for COM20020 */
  278.     backplane,        /* Backplane flag for COM20020 */     
  279.     setup,        /* Contents of setup register */
  280.     intmask;        /* current value of INTMASK register */
  281.   short intx,        /* in TX routine? */
  282.     in_txhandler,    /* in TX_IRQ handler? */
  283.     sending,        /* transmit in progress? */
  284.     lastload_dest,    /* can last loaded packet be acked? */
  285.     lasttrans_dest;    /* can last TX'd packet be acked? */
  286.   
  287. #if defined(DETECT_RECONFIGS) && defined(RECON_THRESHOLD)
  288.   time_t first_recon,    /* time of "first" RECON message to count */
  289.     last_recon;        /* time of most recent RECON */
  290.   int num_recons,    /* number of RECONs between first and last. */
  291.     network_down;    /* do we think the network is down? */
  292. #endif
  293.   
  294.   struct timer_list timer; /* the timer interrupt struct */
  295.   struct Incoming incoming[256];    /* one from each address */
  296.   struct Outgoing outgoing; /* packet currently being sent */
  297.   
  298.   int card_type;
  299.   char *card_type_str;
  300.   
  301.   void (*inthandler) (struct device *dev);
  302.   int (*arcnet_reset) (struct device *dev, int reset_delay);
  303.   void (*asetmask) (struct device *dev, u_char mask);
  304.   void (*acommand) (struct device *dev, u_char command);
  305.   u_char (*astatus) (struct device *dev);
  306.   void (*en_dis_able_TX) (struct device *dev, int enable); 
  307.   void (*prepare_tx)(struct device *dev,u_char *hdr,int hdrlen,
  308.              char *data,int length,int daddr,int exceptA, int offset);
  309.   void (*openclose_device)(int open);  
  310.   
  311.   struct device *adev;    /* RFC1201 protocol device */
  312.   
  313.   /* These are last to ensure that the chipset drivers don't depend on the
  314.    * CONFIG_ARCNET_ETH and CONFIG_ARCNET_1051 options. 
  315.    */
  316.   
  317. #ifdef CONFIG_ARCNET_ETH
  318.   struct device *edev;    /* Ethernet-Encap device */
  319. #endif
  320.   
  321. #ifdef CONFIG_ARCNET_1051
  322.   struct device *sdev;    /* RFC1051 protocol device */
  323. #endif
  324. };
  325.  
  326. /* Functions exported by arcnet.c
  327.  */
  328.  
  329. #if ARCNET_DEBUG_MAX & D_SKB
  330. extern void arcnet_dump_skb(struct device *dev,struct sk_buff *skb,
  331.                 char *desc);
  332. #else
  333. #define arcnet_dump_skb(dev,skb,desc) ;
  334. #endif
  335.  
  336. #if (ARCNET_DEBUG_MAX & D_RX) || (ARCNET_DEBUG_MAX & D_TX)
  337. extern void arcnet_dump_packet(struct device *dev,u_char *buffer,int ext,
  338.                    char *desc);
  339. #else
  340. #define arcnet_dump_packet(dev,buffer,ext,desc) ;
  341. #endif
  342.  
  343. extern void arcnet_tx_done(struct device *dev, struct arcnet_local *lp);
  344. extern void arcnet_makename(char *device);
  345. extern void arcnet_interrupt(int irq,void *dev_id,struct pt_regs *regs);
  346. extern void arcnet_setup(struct device *dev);
  347. extern int arcnet_go_tx(struct device *dev,int enable_irq);
  348. extern void arcnetA_continue_tx(struct device *dev);
  349. extern void arcnet_rx(struct arcnet_local *lp, u_char *arcsoft, short length, int saddr, int daddr);
  350. extern void arcnet_use_count(int open);
  351.  
  352.  
  353. #endif  /* __KERNEL__ */
  354. #endif    /* _LINUX_ARCDEVICE_H */
  355.